/*
 *    Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * @author 品讯科技
 */
package com.px.pa.modulars.circle.service.impl;

import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.px.msg.IMessageService;
import com.px.msg.MessageService;
import com.px.msg.vo.SendMessageParam;
import com.px.pa.modulars.circle.entity.*;
import com.px.pa.modulars.circle.mapper.CircleNoticeConfigMapper;
import com.px.pa.modulars.circle.service.*;
import io.swagger.models.auth.In;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * 
 *
 * @author 品讯科技
 * @date 2024-08
 */
@Service
public class CircleNoticeConfigServiceImpl extends ServiceImpl<CircleNoticeConfigMapper, CircleNoticeConfig> implements CircleNoticeConfigService {

    @Autowired
    private CircleUserService circleUserService;
    @Autowired
    private MessageService messageService;
    @Autowired
    private CircleNoticeConfigService circleNoticeConfigService;
    @Autowired
    private CircleActivitySignService circleActivitySignService;
    @Autowired
    private CircleActivityService circleActivityService;
    @Autowired
    private CircleDynamicService circleDynamicService;


    @Override
    public void companyAcSignRelease(String name,String details,Integer id,String tenant) {
        CircleNoticeConfig circleNoticeConfig =  circleNoticeConfigService.getOne(new QueryWrapper<CircleNoticeConfig>()
                .eq("tenant_code",tenant));
       String detail = details.replaceAll("\\&[a-zA-Z]{1,10};", "").replaceAll("<[^>]*>", "").replaceAll("[(/>)<]", "");
        if(StringUtils.isNotBlank(circleNoticeConfig.getConfig())){
            if(circleNoticeConfig.getCompanyAcSignRelease()== 1){  //判断活动报名开始通知是否开启
                List<String> l = Arrays.asList(org.apache.commons.lang3.StringUtils.split(circleNoticeConfig.getConfig(), ","));
                if(l.size() ==2){
                    List<CircleUser> circleUserList =  circleUserService.list(new QueryWrapper<CircleUser>()
                            .ne("is_tourists",2)
                            .eq("is_del",1));
                    circleUserList.forEach(a->{
                        SendMessageParam msgParam = new SendMessageParam();
                        msgParam.setMethod(IMessageService.METHOD_SMS);
                        msgParam.setKey("companyAcSignRelease");
                        msgParam.putData("aname", "“"+name+"”", 20);
                        msgParam.addTo(a.getPhone());
                        this.messageService.send(msgParam);
                    });

                    circleUserList.forEach(a->{
                        SendMessageParam msgParam1 = new SendMessageParam();
                        msgParam1.setMethod(IMessageService.METHOD_WX);
                        msgParam1.setKey("companyAcSignRelease");
                        msgParam1.putData("thing1", name, 20);
                        msgParam1.putData("thing4","公司活动报名开始");
                       // details = details.replaceAll("\\&[a-zA-Z]{1,10};", "").replaceAll("<[^>]*>", "").replaceAll("[(/>)<]", "");
                        msgParam1.putData("thing6",detail,20);
                        msgParam1.putOtherData("id", String.valueOf(id));
                        msgParam1.addTo(a.getOpenId());
                        this.messageService.send(msgParam1);
                    });

                }else {
                 if("2".equals(l.get(0))){
                     List<CircleUser> circleUserList =  circleUserService.list(new QueryWrapper<CircleUser>()
                             .ne("is_tourists",2)
                     .eq("is_del",1));
                    circleUserList.forEach(a->{
                        SendMessageParam msgParam = new SendMessageParam();
                        msgParam.setMethod(IMessageService.METHOD_SMS);
                        msgParam.setKey("companyAcSignRelease");
                        msgParam.putData("aname", "“"+name+"”", 20);
                        msgParam.addTo(a.getPhone());
                        this.messageService.send(msgParam);
                    });

                 }else {

                     List<CircleUser> circleUserList =  circleUserService.list(new QueryWrapper<CircleUser>()
                             .ne("is_tourists",2)
                             .eq("is_del",1));
                    circleUserList.forEach(a->{
                        SendMessageParam msgParam1 = new SendMessageParam();
                        msgParam1.setMethod(IMessageService.METHOD_WX);
                        msgParam1.setKey("companyAcSignRelease");
                        msgParam1.putData("thing1", name, 20);
                        msgParam1.putData("thing4","公司活动报名开始");
                        msgParam1.putData("thing6",detail,20);
                        msgParam1.putOtherData("id", String.valueOf(id));
                        msgParam1.addTo(a.getOpenId());
                        this.messageService.send(msgParam1);
                    });

                 }
                }

            }

        }
    }

    @Override
    public void companyAcStart(String name, String details, Integer id,String tenant) {
        CircleNoticeConfig circleNoticeConfig =  circleNoticeConfigService.getOne(new QueryWrapper<CircleNoticeConfig>()
        .eq("tenant_code",tenant));
        String  detail = details.replaceAll("\\&[a-zA-Z]{1,10};", "").replaceAll("<[^>]*>", "").replaceAll("[(/>)<]", "");
        List<CircleActivitySign> circleActivitySignList =   circleActivitySignService.list(new QueryWrapper<CircleActivitySign>().eq("id",id));
        List<CircleUser> circleUserList =  new ArrayList<>();
        circleActivitySignList.forEach(circleActivitySign -> {
          CircleUser circleUser =  circleUserService.getById(circleActivitySign.getUserId());
            circleUserList.add(circleUser);
        });
        if(StringUtils.isNotBlank(circleNoticeConfig.getConfig())){
            if(circleNoticeConfig.getCompanyAcStart()== 1){  //判断活动报名开始通知是否开启
                List<String> l = Arrays.asList(org.apache.commons.lang3.StringUtils.split(circleNoticeConfig.getConfig(), ","));
                if(l.size() ==2){

                    circleUserList.forEach(a->{
                        SendMessageParam msgParam = new SendMessageParam();
                        msgParam.setMethod(IMessageService.METHOD_SMS);
                        msgParam.setKey("companyAcStart");
                        msgParam.putData("aname", "“"+name+"”", 20);
                        msgParam.addTo(a.getPhone());
                        this.messageService.send(msgParam);
                    });

                    circleUserList.forEach(a->{
                        SendMessageParam msgParam1 = new SendMessageParam();
                        msgParam1.setMethod(IMessageService.METHOD_WX);
                        msgParam1.setKey("companyAcSignRelease");
                        msgParam1.putData("thing1", name, 20);
                        msgParam1.putData("thing4","公司活动将在30分钟后开始");
                        msgParam1.putData("thing6",detail,20);
                     //   msgParam1.putOtherData("id", String.valueOf(id));
                        msgParam1.addTo(a.getOpenId());
                        this.messageService.send(msgParam1);
                    });

                }else {
                    if("2".equals(l.get(0))){
                        circleUserList.forEach(a->{
                            SendMessageParam msgParam = new SendMessageParam();
                            msgParam.setMethod(IMessageService.METHOD_SMS);
                            msgParam.setKey("companyAcStart");
                            msgParam.putData("aname", "“"+name+"”", 20);
                            msgParam.addTo(a.getPhone());
                            this.messageService.send(msgParam);
                        });

                    }else {
                        circleUserList.forEach(a->{
                            SendMessageParam msgParam1 = new SendMessageParam();
                            msgParam1.setMethod(IMessageService.METHOD_WX);
                            msgParam1.setKey("companyAcSignRelease");
                            msgParam1.putData("thing1", name, 20);
                            msgParam1.putData("thing4","公司活动将在30分钟后开始");
                          //  details = details.replaceAll("\\&[a-zA-Z]{1,10};", "").replaceAll("<[^>]*>", "").replaceAll("[(/>)<]", "");
                            msgParam1.putData("thing6",detail,20);
                            msgParam1.putOtherData("id", String.valueOf(id));
                            msgParam1.addTo(a.getOpenId());
                            this.messageService.send(msgParam1);
                        });

                    }
                }

            }

        }

    }

    @Override
    public void personalAcStart(Integer aid,String tenant) {

        CircleNoticeConfig circleNoticeConfig =  circleNoticeConfigService.getOne(new QueryWrapper<CircleNoticeConfig>()
        .eq("tenant_code",tenant));
       CircleActivity circleActivity = circleActivityService.getById(aid);
       List<CircleActivitySign> circleActivitySignList = circleActivitySignService.list(new QueryWrapper<CircleActivitySign>().eq("activity_id",aid));
        List<CircleUser> circleUserList =  new ArrayList<>();
        circleActivitySignList.forEach(a->{
          CircleUser circleUser =  circleUserService.getById(a.getUserId());
            circleUserList.add(circleUser);
        });

        if(StringUtils.isNotBlank(circleNoticeConfig.getConfig())){
            if(circleNoticeConfig.getPersonalAcStart()== 1){  //判断个人活动开始通知是否开启
                List<String> l = Arrays.asList(org.apache.commons.lang3.StringUtils.split(circleNoticeConfig.getConfig(), ","));
                if(l.size() ==2){
                    circleUserList.forEach(a->{
                        SendMessageParam msgParam = new SendMessageParam();
                        msgParam.setMethod(IMessageService.METHOD_SMS);
                        msgParam.setKey("personalAcStart");
                        msgParam.putData("aname", "“"+circleActivity.getTotle()+"”", 20);
                        msgParam.putOtherData("id",aid.toString());
                        msgParam.addTo(a.getPhone());
                        this.messageService.send(msgParam);

                    });
                    circleUserList.forEach(a->{
                        SendMessageParam msgParam1 = new SendMessageParam();
                        msgParam1.setMethod(IMessageService.METHOD_WX);
                        msgParam1.setKey("companyAcSignRelease");
                        msgParam1.putData("thing1", circleActivity.getTotle(), 20);
                        msgParam1.putData("thing4","个人活动将在30分钟后开始");
                        msgParam1.putData("thing6",circleActivity.getDetails(),20);
                        msgParam1.putOtherData("id",aid.toString());
                        msgParam1.addTo(a.getOpenId());
                        this.messageService.send(msgParam1);
                    });

                }else {
                    if("2".equals(l.get(0))){
                        circleUserList.forEach(a->{
                            SendMessageParam msgParam = new SendMessageParam();
                            msgParam.setMethod(IMessageService.METHOD_SMS);
                            msgParam.setKey("personalAcStart");
                            msgParam.putData("aname", "“"+circleActivity.getTotle()+"”", 20);
                            msgParam.putOtherData("id",aid.toString());
                            msgParam.addTo(a.getPhone());
                            this.messageService.send(msgParam);
                        });

                    }else {
                        circleUserList.forEach(a->{
                            SendMessageParam msgParam1 = new SendMessageParam();
                            msgParam1.setMethod(IMessageService.METHOD_WX);
                            msgParam1.setKey("companyAcSignRelease");
                            msgParam1.putData("thing1", circleActivity.getTotle(), 20);
                            msgParam1.putData("thing4","个人活动将在30分钟后开始");
                            // details = details.replaceAll("\\&[a-zA-Z]{1,10};", "").replaceAll("<[^>]*>", "").replaceAll("[(/>)<]", "");
                            msgParam1.putData("thing6",circleActivity.getDetails(),20);
                            msgParam1.putOtherData("id",aid.toString());
                            msgParam1.addTo(a.getOpenId());
                            this.messageService.send(msgParam1);
                        });

                    }
                }

            }

        }
    }

    @Override
    public void personalAcCancel(Integer aid,String tenant) {

        CircleNoticeConfig circleNoticeConfig =  circleNoticeConfigService.getOne(new QueryWrapper<CircleNoticeConfig>()
                .eq("tenant_code",tenant));
        CircleActivity circleActivity = circleActivityService.getById(aid);
        List<CircleActivitySign> circleActivitySignList = circleActivitySignService.list(new QueryWrapper<CircleActivitySign>().eq("activity_id",aid));
        List<CircleUser> circleUserList =  new ArrayList<>();
        circleActivitySignList.forEach(a->{
            CircleUser circleUser =  circleUserService.getById(a.getUserId());
            circleUserList.add(circleUser);
        });

        if(StringUtils.isNotBlank(circleNoticeConfig.getConfig())){
            if(circleNoticeConfig.getPersonalAcCancel()== 1){  //判断个人活动开始通知是否开启
                List<String> l = Arrays.asList(org.apache.commons.lang3.StringUtils.split(circleNoticeConfig.getConfig(), ","));
                if(l.size() ==2){
                    circleUserList.forEach(a->{
                        SendMessageParam msgParam = new SendMessageParam();
                        msgParam.setMethod(IMessageService.METHOD_SMS);
                        msgParam.setKey("personalAcCancel");
                        msgParam.putData("aname", "“"+circleActivity.getTotle()+"”", 20);
                        msgParam.putOtherData("id",aid.toString());
                        msgParam.addTo(a.getPhone());
                        this.messageService.send(msgParam);
                    });

                    circleUserList.forEach(a->{
                        SendMessageParam msgParam1 = new SendMessageParam();
                        msgParam1.setMethod(IMessageService.METHOD_WX);
                        msgParam1.setKey("companyAcSignRelease");
                        msgParam1.putData("thing1", circleActivity.getTotle(), 20);
                        msgParam1.putData("thing4","个人活动被取消");
                        msgParam1.putData("thing6",circleActivity.getDetails(),20);
                        msgParam1.putOtherData("id",aid.toString());
                        msgParam1.addTo(a.getOpenId());
                        this.messageService.send(msgParam1);
                    });

                }else {
                    if("2".equals(l.get(0))){
                        circleUserList.forEach(a->{
                            SendMessageParam msgParam = new SendMessageParam();
                            msgParam.setMethod(IMessageService.METHOD_SMS);
                            msgParam.setKey("personalAcCancel");
                            msgParam.putData("aname", "“"+circleActivity.getTotle()+"”", 20);
                            msgParam.addTo(a.getPhone());
                            msgParam.putOtherData("id",aid.toString());
                            this.messageService.send(msgParam);
                        });

                    }else {
                        circleUserList.forEach(a->{
                            SendMessageParam msgParam1 = new SendMessageParam();
                            msgParam1.setMethod(IMessageService.METHOD_WX);
                            msgParam1.setKey("companyAcSignRelease");
                            msgParam1.putData("thing1", circleActivity.getTotle(), 20);
                            msgParam1.putData("thing4","个人活动被取消");
                            msgParam1.putData("thing6",circleActivity.getDetails(),20);
                            msgParam1.putOtherData("id",aid.toString());

                            msgParam1.addTo(a.getPhone());
                            this.messageService.send(msgParam1);
                        });

                    }
                }

            }

        }
    }

    @Override
    public void companyAcSignSuccess(Integer aid, Integer user,String tenant) {
        CircleNoticeConfig circleNoticeConfig =  circleNoticeConfigService.getOne(new QueryWrapper<CircleNoticeConfig>()
                .eq("tenant_code",tenant));
        CircleActivity circleActivity = circleActivityService.getById(aid);
        CircleUser circleUser =  circleUserService.getById(user);
        if(StringUtils.isNotBlank(circleNoticeConfig.getConfig())){
            if(circleNoticeConfig.getCompanyAcSignSuccess()== 1){  //判断个人活动开始通知是否开启
                List<String> l = Arrays.asList(org.apache.commons.lang3.StringUtils.split(circleNoticeConfig.getConfig(), ","));
                if(l.size() ==2){
                    SendMessageParam msgParam = new SendMessageParam();
                    msgParam.setMethod(IMessageService.METHOD_SMS);
                    msgParam.setKey("companyAcSignSuccess");
                    msgParam.putData("amane", "“"+circleActivity.getTotle()+"”", 20);
                    msgParam.addTo(circleUser.getPhone());
                    this.messageService.send(msgParam);
                    SendMessageParam msgParam1 = new SendMessageParam();
                    msgParam1.setMethod(IMessageService.METHOD_WX);
                    msgParam1.setKey("companyAcSignRelease");
                    msgParam1.putData("thing1", circleActivity.getTotle(), 20);
                    msgParam1.putData("thing4","活动报名成功");
                    String details = circleActivity.getDetails().replaceAll("\\&[a-zA-Z]{1,10};", "").replaceAll("<[^>]*>", "").replaceAll("[(/>)<]", "");
                    msgParam1.putData("thing6",details,20);
                    msgParam1.putOtherData("id",aid.toString());
                    msgParam1.addTo(circleUser.getOpenId());
                    this.messageService.send(msgParam1);
                }else {
                    if("2".equals(l.get(0))){
                        SendMessageParam msgParam = new SendMessageParam();
                        msgParam.setMethod(IMessageService.METHOD_SMS);
                        msgParam.setKey("companyAcSignSuccess");
                        msgParam.putData("amane", "“"+circleActivity.getTotle()+"”", 20);
                        msgParam.putOtherData("id",aid.toString());
                        msgParam.addTo(circleUser.getPhone());
                        this.messageService.send(msgParam);
                    }else {
                        SendMessageParam msgParam1 = new SendMessageParam();
                        msgParam1.setMethod(IMessageService.METHOD_WX);
                        msgParam1.setKey("companyAcSignRelease");
                        msgParam1.putData("thing1", circleActivity.getTotle(), 20);
                        msgParam1.putData("thing4","活动报名成功");
                        String details = circleActivity.getDetails().replaceAll("\\&[a-zA-Z]{1,10};", "").replaceAll("<[^>]*>", "").replaceAll("[(/>)<]", "");
                        msgParam1.putData("thing6",details,20);
                        msgParam1.putOtherData("id",aid.toString());
                        msgParam1.addTo(circleUser.getOpenId());

                        this.messageService.send(msgParam1);
                    }
                }

            }

        }
    }

    @Override
    public void problemAnswer(Date time, String name,Integer pid,String tenant) {
        CircleNoticeConfig circleNoticeConfig =  circleNoticeConfigService.getOne(new QueryWrapper<CircleNoticeConfig>()
                .eq("tenant_code",tenant));
       CircleDynamic circleDynamic = circleDynamicService.getById(pid);
       CircleUser circleUser =  circleUserService.getById(circleDynamic.getUid());
        if(StringUtils.isNotBlank(circleNoticeConfig.getConfig())){
            if(circleNoticeConfig.getProblemAnswer()== 1){  //判断个人活动开始通知是否开启
                List<String> l = Arrays.asList(org.apache.commons.lang3.StringUtils.split(circleNoticeConfig.getConfig(), ","));
                if(l.size() ==2){
                    SendMessageParam msgParam = new SendMessageParam();
                    msgParam.setMethod(IMessageService.METHOD_SMS);
                    msgParam.setKey("problemAnswer");
                    msgParam.putData("qname", "“"+circleDynamic.getTitle()+"”", 20);
                    msgParam.addTo(circleUser.getPhone());
                    this.messageService.send(msgParam);
                    SendMessageParam msgParam1 = new SendMessageParam();
                    msgParam1.setMethod(IMessageService.METHOD_WX);
                    msgParam1.setKey("problemAnswer");
                    msgParam1.putData("date2", DateUtil.format(time, "yyyy-MM-dd HH:mm"));
                    msgParam1.putData("name1",name);
                    msgParam1.putOtherData("id",pid.toString());
                    msgParam1.addTo(circleUser.getOpenId());
                    this.messageService.send(msgParam1);
                }else {
                    if("2".equals(l.get(0))){
                        SendMessageParam msgParam = new SendMessageParam();
                        msgParam.setMethod(IMessageService.METHOD_SMS);
                        msgParam.setKey("problemAnswer");
                        msgParam.putData("qname", "“"+circleDynamic.getTitle()+"”", 20);
                        msgParam.putOtherData("id",pid.toString());
                        msgParam.addTo(circleUser.getPhone());
                        this.messageService.send(msgParam);
                    }else {
                        SendMessageParam msgParam1 = new SendMessageParam();
                        msgParam1.setMethod(IMessageService.METHOD_WX);
                        msgParam1.setKey("problemAnswer");
                        msgParam1.putData("date2", DateUtil.format(time, "yyyy-MM-dd HH:mm"));
                        msgParam1.putData("name1",name);
                        msgParam1.putOtherData("id",pid.toString());
                        msgParam1.addTo(circleUser.getOpenId());
                        this.messageService.send(msgParam1);
                    }
                }

            }

        }
    }

    @Override
    public void dynamicIssee(CircleUser circleUser,String way) {

        List<String> l = Arrays.asList(org.apache.commons.lang3.StringUtils.split(way, ","));
        if(l.size()==2){
            SendMessageParam msgParam = new SendMessageParam();
            msgParam.setMethod(IMessageService.METHOD_SMS);
            msgParam.setKey("dynamicIssee");
            msgParam.putData("tname", "《"+circleUser.getDynamicName()+"》", 20);
            msgParam.addTo(circleUser.getPhone());
            this.messageService.send(msgParam);
            SendMessageParam msgParam1 = new SendMessageParam();
            msgParam1.setMethod(IMessageService.METHOD_WX);
            msgParam1.setKey("dynamicIssee");
            msgParam1.putData("thing1",circleUser.getDynamicName());
            msgParam1.putData("thing2","您有一篇知识未读");
            msgParam1.putData("number3","1");
          //  msgParam1.putOtherData("id",circleUser.getDynamic().toString());
            msgParam1.addTo(circleUser.getOpenId());
            this.messageService.send(msgParam1);
        }else {
            if("2".equals(l.get(0))){  //微信
                SendMessageParam msgParam1 = new SendMessageParam();
                msgParam1.setMethod(IMessageService.METHOD_WX);
                msgParam1.setKey("dynamicIssee");
                msgParam1.putData("thing1",circleUser.getDynamicName());
                msgParam1.putData("thing2","您有一篇知识未读");
                msgParam1.putData("number3","1");
            //    msgParam1.putOtherData("id",circleUser.getDynamic().toString());
                msgParam1.addTo(circleUser.getOpenId());
                this.messageService.send(msgParam1);
            }else {
                SendMessageParam msgParam = new SendMessageParam();
                msgParam.setMethod(IMessageService.METHOD_SMS);
                msgParam.setKey("dynamicIssee");
                 msgParam.putData("tname", "《"+circleUser.getDynamicName()+"》", 20);
                msgParam.addTo(circleUser.getPhone());
                this.messageService.send(msgParam);
            }

        }
    }

    @Override
    public void activityExit(Integer uid, Integer aid) {

       CircleUser circleUser = circleUserService.getById(uid);
      //  CircleUser circleUser1 =  circleUserService.getById(userid);
     CircleActivity circleActivity =   circleActivityService.getById(aid);
        SendMessageParam msgParam = new SendMessageParam();
        msgParam.setMethod(IMessageService.METHOD_SMS);
        msgParam.setKey("activityExit");
         msgParam.putData("aname", "“"+circleActivity.getTotle()+"”", 20);
        msgParam.addTo(circleUser.getPhone());
        this.messageService.send(msgParam);
    }


    @Override
    public void taskDynamicIssee(CircleUser circleUser,String way) {

        List<String> l = Arrays.asList(org.apache.commons.lang3.StringUtils.split(way, ","));
        if(l.size()==2){
            SendMessageParam msgParam = new SendMessageParam();
            msgParam.setMethod(IMessageService.METHOD_SMS);
            msgParam.setKey("dynamicIssee");
            msgParam.putData("tname", "《"+circleUser.getDynamicName()+"》", 20);
            msgParam.addTo(circleUser.getPhone());
            this.messageService.send(msgParam);
            SendMessageParam msgParam1 = new SendMessageParam();
            msgParam1.setMethod(IMessageService.METHOD_WX);
            msgParam1.setKey("dynamicIssee");
            msgParam1.putData("thing1",circleUser.getDynamicName());
            msgParam1.putData("thing2","您有一个任务未完成");
            msgParam1.putData("number3","1");
           // msgParam1.putOtherData("id",circleUser.getDynamic().toString());
            msgParam1.addTo(circleUser.getOpenId());
            this.messageService.send(msgParam1);
        }else {
            if("2".equals(l.get(0))){  //微信
                SendMessageParam msgParam1 = new SendMessageParam();
                msgParam1.setMethod(IMessageService.METHOD_WX);
                msgParam1.setKey("dynamicIssee");
                msgParam1.putData("thing1",circleUser.getDynamicName());
                msgParam1.putData("thing2","您有一个任务未完成");
                msgParam1.putData("number3","1");
 //               msgParam1.putOtherData("id",circleUser.getDynamic().toString());
                msgParam1.addTo(circleUser.getOpenId());
                this.messageService.send(msgParam1);
            }else {
                SendMessageParam msgParam = new SendMessageParam();
                msgParam.setMethod(IMessageService.METHOD_SMS);
                msgParam.setKey("dynamicIssee");
                msgParam.putData("tname", "《"+circleUser.getDynamicName()+"》", 20);
                msgParam.addTo(circleUser.getPhone());
                this.messageService.send(msgParam);
            }

        }
    }


    @Override
    public void problemAnswer1(String name,Integer pid ,Integer contentId,String tenant) {
        CircleNoticeConfig circleNoticeConfig =  circleNoticeConfigService.getOne(new QueryWrapper<CircleNoticeConfig>()
                .eq("tenant_code",tenant));
     CircleDynamic circleDynamic =   circleDynamicService.getById(pid);
        CircleUser circleUser =  circleUserService.getById(contentId);
        if(StringUtils.isNotBlank(circleNoticeConfig.getConfig())){
            if(circleNoticeConfig.getProblemAnswer()== 1){  //判断个人活动开始通知是否开启
                List<String> l = Arrays.asList(org.apache.commons.lang3.StringUtils.split(circleNoticeConfig.getConfig(), ","));
                if(l.size() ==2){
                    SendMessageParam msgParam = new SendMessageParam();
                    msgParam.setMethod(IMessageService.METHOD_SMS);
                    msgParam.setKey("dynamicAnswer");
                    msgParam.putData("qname", "“"+circleDynamic.getTitle()+"”", 20);
                    msgParam.addTo(circleUser.getPhone());
                    this.messageService.send(msgParam);
                    SendMessageParam msgParam1 = new SendMessageParam();
                    msgParam1.setMethod(IMessageService.METHOD_WX);
                    msgParam1.setKey("dynamicAnswer");
                    msgParam1.putData("date2", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm"));
                    msgParam1.putData("name1",name);
                    msgParam1.putOtherData("id",pid.toString());
                    msgParam1.addTo(circleUser.getOpenId());
                    this.messageService.send(msgParam1);
                }else {
                    if("2".equals(l.get(0))){
                        SendMessageParam msgParam = new SendMessageParam();
                        msgParam.setMethod(IMessageService.METHOD_SMS);
                        msgParam.setKey("dynamicAnswer");
                        msgParam.putData("qname", "“"+circleDynamic.getTitle()+"”", 20);
                        msgParam.putOtherData("id",pid.toString());
                        msgParam.addTo(circleUser.getPhone());
                        this.messageService.send(msgParam);
                    }else {
                        SendMessageParam msgParam1 = new SendMessageParam();
                        msgParam1.setMethod(IMessageService.METHOD_WX);
                        msgParam1.setKey("dynamicAnswer");
                        msgParam1.putData("date2", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm"));
                        msgParam1.putData("name1",name);
                        msgParam1.putOtherData("id",pid.toString());
                        msgParam1.addTo(circleUser.getOpenId());
                        this.messageService.send(msgParam1);
                    }
                }

            }

        }
    }


}
